package com.signway.module_signway_adapter_common_3;

import android.content.Context;
import android.util.Log;

import com.signway.module_signway_adapter_common_3.constant.ScreenResolutionBean;
import com.signway.open.api.IOpenDisplayApi;
import com.signway.opensdk.interfaces.base.Callback1;
import com.signway.opensdk.internal.command.signway.ApiConst;
import com.signway.opensdk.model.SDKResult;
import com.signway.opensdk.sdk.SDK;

/*
 * -----------------------------------------------------------------
 * Copyright (C) 2011-2019, by your Signway, All rights reserved.
 * -----------------------------------------------------------------
 *
 * ProjectName: droid5119
 *
 * Author: Administrator
 *
 * Email: pf.wang@Signway.cn
 *
 * Description:
 *
 * -----------------------------------------------------------------
 * 2019-5-29 : Create SignwayDisplayApi.java
 * -----------------------------------------------------------------
 */
public class SignwayDisplayApi implements IOpenDisplayApi {
    private static final String TAG = "SignwayDisplayApi";
    private static SignwayDisplayApi mSignwayDisplayApi;
    private static Context mContext;

    public static synchronized SignwayDisplayApi getInstance(Context context) {
        mContext = context;
        if (mSignwayDisplayApi == null) {
            mSignwayDisplayApi = new SignwayDisplayApi(context);
        }
        return mSignwayDisplayApi;
    }

    public SignwayDisplayApi(Context context) {
        this.mContext = context;
    }

    public void setBackLightEnable(boolean isEnabled) {
        Log.i(TAG, "setBackLightEnable: ");
    }

    public void setBrightness(int value) {
        Log.i(TAG, "setBrightness: ");
    }

    //对比度
    public void setContrast(int value) {
        Log.i(TAG, "setContrast: ");
    }

    public void setColor(int value) {
        Log.i(TAG, "setColor: ");
    }

    public void setTint(int value) {
        Log.i(TAG, "setTint: ");
    }

    public void setSharpness(int value) {
        Log.i(TAG, "setSharpness: ");
    }

    @Override
    public String getLvdsResolution(int value) {
        final String[] s = new String[1];
        int lvdsResolution = 0;
        Log.d(TAG, "获得屏幕分辨率");
        SDK.displayApi().getScreenResolution(ApiConst.ScreenID.SCREEN_ID_LVDS, new Callback1<SDKResult<String>>() {
            @Override
            public void onMsg(SDKResult<String> stringSDKResult) {
                s[0] = stringSDKResult.getContent();
            }
        });
        Log.d(TAG, "得到屏幕分辨率结果：" + s[0]);

        if(s[0] != null && s[0].contains("@")){
            ScreenResolutionBean screenResolutionBean = new ScreenResolutionBean();
            lvdsResolution = screenResolutionBean.screenResolution(s[0]);
        }
        return lvdsResolution + "";
    }

    @Override
    public void setLvdsResolution(int value) {
        Log.i(TAG, "setLvdsResolution: ");
    }

    @Override
    public void setBacklightInverse(int screen, int status) {

    }

    @Override
    public int getScreenBacklightInverse(int id) {
        return 0;
    }

    @Override
    public void setBacklightMode(int screen, int mode) {

    }

    @Override
    public int getScreenBacklightMode(int id) {
        return 0;
    }

    @Override
    public void setScreenBrightness(int id, int brightness) {

    }

    @Override
    public int getScreenBrightness(int id) {
        return 0;
    }

    @Override
    public boolean setScreenOnoff(int id, boolean onoff) {
        return false;
    }

    @Override
    public boolean getScreenStatus(int id) {
        return false;
    }

    @Override
    public boolean setScreenResolution(int id, String resolution) {
        return false;
    }

    @Override
    public String getScreenResolution(int id) {
        return null;
    }

    @Override
    public boolean setHdmiOnoff(boolean onoff) {
        return false;
    }

    @Override
    public boolean getHdmiOnoff() {
        return false;
    }

    @Override
    public boolean setHdmiResolution(int resolution) {
        return false;
    }

    @Override
    public String getHdmiResolution() {
        return null;
    }

    @Override
    public boolean setLvdsMode(String id, int mode) {
        return false;
    }

    @Override
    public int getLvdsMode(String id) {
        return 0;
    }

    @Override
    public boolean setLvdsSwap(String id, int swap) {
        return false;
    }

    @Override
    public int getLvdsSwap(String id) {
        return 0;
    }

    @Override
    public boolean setLvdsChannel(int screen, int channel) {
        return false;
    }

    @Override
    public int getLvdsChannel(int screen) {
        return 0;
    }
}
